package com.ari.user.contorller;

import com.ari.user.config.PatternProperties;
import com.ari.user.pojo.User;
import com.ari.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Slf4j
@RestController
@RequestMapping("/user")
//@RefreshScope //搭配 @Value 使用
public class UserController {

    @Autowired
    private UserService userService;

    //@Value("${pattern.dateformat}")
    //private String dateformat;

    //@GetMapping("now")
    //public String now(){
    //    //格式化时间
    //    return LocalDateTime.now().format(DateTimeFormatter.ofPattern(dateformat));
    //}
    @Autowired
    private PatternProperties patternProperties;

    @GetMapping("now2")
    public String now2(){
        //格式化时间
        return LocalDateTime.now().format(DateTimeFormatter.ofPattern(patternProperties.dateformat));
    }


    @GetMapping("{id}")
    public User getUser(@PathVariable("id") long id, @RequestHeader(value = "sign", required = false) String sign){
        // 根据id查询订单并返回s
        System.out.println(sign);
        System.out.println("sdfasfa");
        log.warn("asdfasdf");
        log.debug(sign);
        return userService.queryUserById(id);
    }
}